﻿<Window xmlns:my="clr-namespace:SimpleControlLibrary"  x:Class="SimpleControlLibrary.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:avalonDock="http://avalondock.codeplex.com"
        Title="查询分析器" 
        WindowStartupLocation="CenterScreen" 
        WindowState="Maximized"
        FontSize="12"
        FontFamily="NSimSun"
        TextOptions.TextFormattingMode="Display"
        TextOptions.TextRenderingMode="ClearType"
        Icon="/logo2.ico" 
        mc:Ignorable="d" 
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:ui="clr-namespace:SimpleControlLibrary.UI"
         xmlns:ctrl="clr-namespace:BaseControlLibrary;assembly=BaseControlLibrary" 
        >
        <!--Style="{StaticResource window}-->
    <!---->
    <Window.Resources>
         <RoutedUICommand Text="打开" x:Key="OpenCommand"/>
        <RoutedUICommand Text="保存" x:Key="SaveCommand"/>
        <RoutedUICommand Text="运行" x:Key="RunCommand" />
        <RoutedUICommand Text="复制" x:Key="copyFieldName"/>
    </Window.Resources>
    <Window.InputBindings>
        <KeyBinding Gesture="F5" Command="{StaticResource RunCommand}"/>
        <KeyBinding Modifiers="Ctrl" Key="O" Command="{StaticResource OpenCommand}"/>
        <KeyBinding Modifiers="Ctrl" Key="S" Command="{StaticResource SaveCommand}"/>
        <KeyBinding Modifiers="Ctrl" Key="C" Command="{StaticResource copyFieldName}"/>
    </Window.InputBindings>
    <Window.CommandBindings>
        <CommandBinding Command="{StaticResource OpenCommand}"
                        Executed="OpenCommandBindingExecuted"/>
        <CommandBinding Command="{StaticResource RunCommand}"
                        Executed="RunCommandBindingExecuted"
                        CanExecute="RunCommandBindingCanExecute"/>
        <CommandBinding Command="{StaticResource SaveCommand}"
                        Executed="SaveCommandBindingExecuted"
                        CanExecute="SaveCommandBindingCanExecute"/>
        <CommandBinding Command="{StaticResource copyFieldName}" 
                        Executed="CopyFieldName_CommandBinding_Executed"/>

    </Window.CommandBindings>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="42"/>
            <RowDefinition Height="209*" />
            <RowDefinition Height="23"/>
        </Grid.RowDefinitions>
        <ToolBar  Name="toolBar1">
           
            <my:ImageButtonControl Source="/QueryResource;component/Images/Tool/Add_32x32.png"
                                   Text="新建数据源"
                                   Command="{Binding ViewModel.CreateDBCommand}"/>
            <my:ImageButtonControl Source="/QueryResource;component/Images/Tool/new-16x16.png"
                                   Text="新建文档"
                                   Command="{Binding ViewModel.AddDocumentCommand}"/>
            <my:ImageButtonControl Source="/QueryResource;component/Images/Tool/open-32x32.png"
                                   Text="打开" KeyGesture="Ctrl+O"
                                   Command="{StaticResource OpenCommand}"/>
            <my:ImageButtonControl Source="/QueryResource;component/Images/Tool/save-32x32.png"
                                   Text="保存" KeyGesture="Ctrl+S" Command="{StaticResource SaveCommand}"/>
            <Separator/>
            <my:ImageButtonControl Source="/QueryResource;component/Images/Tool/undo-32x32.png"
                                   Text="撤销" KeyGesture="Ctrl+Z" Command="Undo"/>
            <my:ImageButtonControl Source="/QueryResource;component/Images/Tool/redo-32x32.png"
                                   Text="重做" KeyGesture="Ctrl+Y" Command="Redo"/>
            <Separator/>
            <my:ImageButtonControl Source="/QueryResource;component/Images/run.png"
                                   Text="运行" KeyGesture="F5" Command="{StaticResource RunCommand}"/>
            <Button Name="BtnVerition" Content="精简模式" Click="BtnVerition_Click"/>
        </ToolBar>
        <StatusBar Grid.Row="2">
            <TextBlock Name="lbFieldName" Text="字段" MinWidth="100"/>
            <TextBlock Name="lbIPname" Text="IP:" MinWidth="100"/>
            <TextBlock Name="lbDBname" Text="数据库连接:" MinWidth="100"/>
            <TextBlock Name="lbUserId" Text="当前用户:" MinWidth="100"/>
            <StatusBarItem HorizontalAlignment="Right">
                <TextBlock Name="lbUpdateInfo" Text="当前版本:" MinWidth="100" />
            </StatusBarItem>
          
        </StatusBar>
        
        
        <avalonDock:DockingManager Grid.Row="1" x:Name="dockManager" AllowMixedOrientation="True" DocumentClosing="DockManagerDocumentClosing"
                                   >
            <!--<avalonDock:DockingManager.Theme>
                <avalonDock:AeroTheme/>
            </avalonDock:DockingManager.Theme>-->
            <avalonDock:DockingManager.DocumentHeaderTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal">
                        <Image Source="{Binding IconSource}" Margin="0,0,4,0"/>
                        <TextBlock Text="{Binding Title}" TextTrimming="CharacterEllipsis"/>
                    </StackPanel>
                </DataTemplate>
            </avalonDock:DockingManager.DocumentHeaderTemplate>
            <avalonDock:LayoutRoot>
                <avalonDock:LayoutPanel Orientation="Horizontal">
                    <avalonDock:LayoutAnchorablePane DockWidth="200">
                        <avalonDock:LayoutAnchorable Title="数据源" CanClose="False">
                            <!--数据源-->
                            <ctrl:DBTreeViewControl x:Name="dbtreeview"/>
                        </avalonDock:LayoutAnchorable>
                    </avalonDock:LayoutAnchorablePane>
                    
                    <avalonDock:LayoutPanel Orientation="Vertical">
                        <avalonDock:LayoutDocumentPaneGroup>
                            <avalonDock:LayoutDocumentPane x:Name="documentGroup">
                                <avalonDock:LayoutDocument Title="文档" x:Name="documentSQL" IconSource="/QueryResource;component/Images/Tool/copy-16x16.png" CanClose="False">
                                    <!--文档-->
                                    <ctrl:SQLControl x:Name="sqlcontrol" Tag="{Binding ElementName=documentSQL}"/>
                                </avalonDock:LayoutDocument>
                            </avalonDock:LayoutDocumentPane>
                        </avalonDock:LayoutDocumentPaneGroup>
                        
                        <avalonDock:LayoutAnchorablePaneGroup DockHeight="300">
                            <avalonDock:LayoutAnchorablePane>
                                <avalonDock:LayoutAnchorable  Title="日志" x:Name="documentLog" CanClose="False">
                                    <!--日志-->
                                   
                                    <ui:LogControl x:Name="logcontrol" />
                                </avalonDock:LayoutAnchorable>
                                <avalonDock:LayoutAnchorable Title="数据" x:Name="documentDS" CanClose="False">
                                    <!--数据-->
                                    <ui:GridViewControl x:Name="gridviewcontrol"/>
                                </avalonDock:LayoutAnchorable>
                            </avalonDock:LayoutAnchorablePane>

                        </avalonDock:LayoutAnchorablePaneGroup>
                    </avalonDock:LayoutPanel>
                    
                    
                    
                </avalonDock:LayoutPanel>
            </avalonDock:LayoutRoot>
        </avalonDock:DockingManager>
    </Grid>
</Window>
